

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	self.Ent = data:GetEntity()
	if self.Ent == nil or self.Ent == NULL then return end
	self.Pos = data:GetOrigin()
	self.DieTime = CurTime() + math.Rand(7.5,9.5)
	self.Velocity 	= Vector( 0, 0, 1 )
	
	self.Emitter = ParticleEmitter( self.Pos )
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )
	if self.Ent == nil or self.Ent == NULL then 
		if self.Emitter then
			self.Emitter:Finish()
		end
	return false end
	if self.DieTime < CurTime() then self.Emitter:Finish() return false end

	self.Pos = self.Ent:GetPos() + Vector(math.Rand(-10,10),math.Rand(-10,10),0)
			
	for i=1,math.random(1,2) do
		local particle = self.Emitter:Add( "effects/muzzleflash"..math.random(1,4), self.Pos )
		particle:SetVelocity( (self.Velocity * math.Rand( 30, 60 )) + WindVector )
		particle:SetDieTime( math.Rand( 0.3, 1 ) )
		particle:SetStartAlpha( math.Rand( 100, 160 ) )
		particle:SetEndAlpha( math.Rand( 30, 60 ) )
		particle:SetStartSize( math.Rand( 15, 25 ) )
		particle:SetEndSize( .1 )
		particle:SetRoll( math.Rand( 0, 360 ) )
		particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
		particle:SetColor( math.Rand( 150, 255 ), math.Rand( 120, 150 ), 100 )
		particle:VelocityDecay( false )
	end
			
	local particle = self.Emitter:Add( "particles/smokey", self.Pos )
	particle:SetVelocity( (self.Velocity * math.Rand( 10, 50 )) + WindVector )
	particle:SetDieTime( math.Rand( 1, 1.5 ) )
	particle:SetStartAlpha( math.Rand( 20, 50 ) )
	particle:SetEndAlpha( math.Rand( 5, 10 ) )
	particle:SetStartSize( math.Rand( 5, 10 ) )
	particle:SetEndSize( math.Rand( 15, 30 ) )
	particle:SetRoll( math.Rand( 0, 360 ) )
	particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
	particle:SetColor( 40,40,40 )
	particle:VelocityDecay( false )

	return true
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	// Do nothing - this effect is only used to spawn the particles in Init
	
end



